package com.jpress.bean;

import java.util.List;
import java.util.Locale;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import com.jpress.facade.Facade;
import com.jpress.model.Blog;

@ManagedBean(name = "systemBean")
@SessionScoped
public class SystemBean {
	private Facade facade = new Facade();
	private String nome;
	private String locale = "pt_BR";
	
	public List<Blog> getListaUltimosBlogs() {
		return facade.latestBlogs(3);
	}
	
	public int getBlogsQtde() {
		return facade.getBlogsQtde();
	}

	public int getAdminsQtde() {
		return facade.getAdminsQtde();
	}

	public int getUsuariosQtde() {
		return facade.getUsuariosQtde();
	}

	public int getPostsQtde() {
		return facade.getPostsQtde();
	}

	public int getComentariosQtde() {
		return facade.getComentariosQtde();
	}
	
	public void exibeNome(){
		System.out.println(this.nome);
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}
	
	public String getLocale(){
		return locale;
	}
	
	public void setLocale(String locale){
		this.locale = locale;
	}
	
	public void alteraLocale(){
		FacesContext fc = FacesContext.getCurrentInstance();
		fc.getViewRoot().setLocale(new Locale(locale));
	}
}
